/*
 * Rating.java
 *
 * This program demonstrates the use of for loop to rate an article.
 *
 */

package com.javarcore;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * 
 * @author ChungND
 */

public class Rating1 {
	/** Creates a new instance of Rating1 */
	public Rating1() {

	}

	/**
	 * @param args
	 *            the command line arguments
	 */

	public static void main(String[] args) {
		int choice;
		int poorCount = 0, fairCount = 0, goodCount = 0, excellentCount = 0;
		Scanner input = new Scanner(System.in);
		
		System.out.println("Tell us what do you think about the content of the article \"Basics of Java\".");
		System.out.println("1. Poor");
		System.out.println("2. Fair");
		System.out.println("3. Good");
		System.out.println("4. Excellent");
		System.out.println("5. Exit");
		
		System.out.println("\n Enter your choice : ");
			choice = input.nextInt();
		
		
		   // Iterate the loop until user enters 5
		
		do	{
			switch(choice)	{
			
			case 1:
				poorCount++;
				break;
				
			case 2:
				fairCount++;
				break;
				
			case 3:
				goodCount++;
				break;
				
			case 4:
				excellentCount++;
				break;
				
			default :
				System.out.println("Invalid input!");
				break;
			}
			System.out.println("\n Enter your choice : ");
			try	{
				choice = input.nextInt();
			}	catch (InputMismatchException e)	{
				System.out.println("Wrong Input !");
				break;
			}
			
		} while (choice != 5);
		System.out.println("\n The article \"Basics of Java\" has received the following ratings : ");
		
		System.out.println("Poor : "+poorCount);
		System.out.println("Fair : "+fairCount);
		System.out.println("Good : "+goodCount);
		System.out.println("Excellent : "+excellentCount );
	}
}
